<?php
/**
* @package DomBase
* @author Oliver Leisalu
*/
class DomLocCounter {
	
	private $dirs = array();
	
	public function __construct() {
		
	}

	public function addDir( $dir ) {
		$this->dirs[] = $dir;
	}
	
	public function count() {
		$sum  = 0;
		foreach( $this->dirs as $dir ) {
			$sum += $this->countDir( $dir );
		}
		return $sum;
	}
	
	private function countDir( $dirPath ) {
		$sum = 0;
		foreach( glob($dirPath.'/*') as $path ) {
			if( is_file($path) ) {
				$sum += $this->countFile( $path );
			} else {
				$sum += $this->countDir( $path );
			}
		}
		return $sum;
	}
	
	private function countFile( $filePath ) {
		return count(file($filePath));
		//$c = file_get_contents($filePath);
		//return substr_count($c,';') + substr($c,'{');
	}
	
	
}
?>